<template>
  <div class="app-container">
    <div style="margin-top: 30px">
      <div
        v-purview-check="{
          modules: 'site_tpl',
          resources: 'site_tpl',
          operates: 'view',
        }"
      >
        查看
      </div>
      含有模块:site_tpl,资源:site_tpl 操作:view 权限
        <el-tag class="permission-sourceCode" type="info">
          v-purview-check="{modules: 'site_tpl',resources: 'site_tpl',operates:
          'view'}"
        </el-tag>
    </div>

    <div style="margin-top: 90px">
      <div
        v-purview-check="{
          modules: 'site_tpl',
          resources: 'site_tpl',
          operates: 'delete',
        }">
       删除
      </div>
       不含有模块:site_tpl,资源:site_tpl 操作:delete 权限
        <el-tag class="permission-sourceCode" type="info">
          v-purview-check="{modules: 'site_tpl',resources: 'site_tpl',operates:
          'delete'}"
        </el-tag>
    </div>
  </div>
</template>

<script>
import permission from "@/directive/permission/index.js"; // 权限判断指令
import {checkPermission} from "@/utils/permission"; // 权限判断函数


export default {
  name: "DirectivePermission",
  components: {  },
  directives: { permission },
  data() {
    return {
      key: 1, // 为了能每次切换权限的时候重新初始化指令
    };
  },
  methods: {
    checkPermission,
    handleRolesChange() {
      this.key++;
    },
  },
};
</script>

<style lang="scss" scoped>
.app-container {
  ::v-deep .permission-alert {
    width: 320px;
    margin-top: 15px;
    background-color: #f0f9eb;
    color: #67c23a;
    padding: 8px 16px;
    border-radius: 4px;
    display: inline-block;
  }
  ::v-deep .permission-sourceCode {
    margin-left: 15px;
  }
  ::v-deep .permission-tag {
    background-color: #ecf5ff;
  }
}
</style>

